package com.sec.android.app.myfiles.fragment.filelist;

import com.sec.android.app.myfiles.module.abstraction.FileRecord;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.reflect.internal.WhiteboxImpl;

import static com.sec.android.app.myfiles.fragment.AbsMyFilesFragment.ActionModeType.EDIT_FILE_FOLDER_OPERATION;
import static com.sec.android.app.myfiles.fragment.AbsMyFilesFragment.ActionModeType.SELECT_FILE_FOLDER_OPERATION;
import static com.sec.android.app.myfiles.fragment.AbsMyFilesFragment.ActionModeType.SELECT_SHARE_FILE_OPERATION;

/**
 * Created by jaebae on 2016-12-05.
 */

public class testFileListFragment {
    private FileListFragment mFragment;

    @Before
    public void setUp() throws Exception {
        mFragment = new FileListFragment();
    }

    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void testOnCreate() {
        try {
            mFragment.onCreate(null);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Test
    public void testOnCreateView() {
        try {
            mFragment.onCreateView(null, null, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testOnViewCreated() {
        try {
            mFragment.onViewCreated(null, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testSetTwFluidScroll() {
        try {
            WhiteboxImpl.invokeMethod(mFragment, "setTwFluidScroll");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testSetTwGoToTop() {
        try {
            WhiteboxImpl.invokeMethod(mFragment, "setTwGoToTop");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testUpdateMenuView() {
        try {
            WhiteboxImpl.invokeMethod(mFragment, "updateMenuView");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testOnConfigurationChanged() {
        try {
            mFragment.onConfigurationChanged(null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testOnResume() {
        try {
            mFragment.onResume();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testGetListItemCount() {
        try {
            mFragment.getListItemCount();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testOnPause() {
        try {
            mFragment.onPause();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testOnStop() {
        try {
            mFragment.onStop();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @Test
    public void testOnDestroy() {
        try {
            mFragment.onDestroy();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testIsItemClickValid() {
        try {
            WhiteboxImpl.invokeMethod(mFragment, "isItemClickValid", 0);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @Test
    public void testOnItemClick() {
        try {
            mFragment.onItemClick(null, null, 0, 0);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void test_OnItemClick() {
        try {
            WhiteboxImpl.invokeMethod(mFragment, "_onItemClick", PowerMockito.mock(FileRecord.class));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testOnItemLongClick() {
        try {
            mFragment.onItemLongClick(null, null, 0, 0);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testSetActionMode() {
        try {
            mFragment.setActionMode(SELECT_FILE_FOLDER_OPERATION);
            mFragment.setActionMode(EDIT_FILE_FOLDER_OPERATION);
            mFragment.setActionMode(SELECT_SHARE_FILE_OPERATION);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testSetDefaultSelection() {
        try {
            WhiteboxImpl.invokeMethod(mFragment, "setDefaultSelection");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testInvalidateView() {
        try {
            WhiteboxImpl.invokeMethod(mFragment, "invalidateView", false, false, false);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testReload() {
        try {
            mFragment.reload();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
